package org.helloroad;

import java.io.Serializable;

import org.ksoap2.serialization.SoapObject;

public class Contact implements Serializable {
	public Integer id;
	public String login;
	public String number;
	public String firstname;
	public String lastname;
	public String address;
	
	/**
	 * Allows to build a Contact from a SoapObject
	 * @param o
	 */
	public Contact(SoapObject o)
	{
		this.id = Integer.parseInt(o.getProperty("id").toString());
		this.login = o.getProperty("login").toString();
		if (o.getProperty("firstname") != null)
			this.firstname = o.getProperty("firstname").toString();
		if (o.getProperty("lastname") != null)
			this.lastname = o.getProperty("lastname").toString();
		this.number = o.getProperty("number").toString();
		if (o.getProperty("address") != null)
			this.address = o.getProperty("address").toString();
	}
	
	public Contact(int id, String login, String number, String firstname,
			String lastname, String address) {
		this.id = id;
		this.login = login;
		this.number = number;
		this.firstname = firstname;
		this.lastname = lastname;
		this.address = address;
	}
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}

	public String getFirstname() {
		return firstname;
	}
	
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	
	public String getLastname() {
		return lastname;
	}
	
	public void setLastname(String lastname){
		this.lastname = lastname;
	}
	
	public String getFullName() {
		return firstname + " " + lastname;
	}

	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	@Override
	public String toString() {
		return login;
	}
}
